/*******************************************************************************
*** Histograms of composition of each firmtype_alt by industry
*******************************************************************************/
  
u "$cur_sample.dta", clear
do $cleaning/renameSOI.do

g label =  "Public Multinational" if firmtype_alt==1
	replace label = "Public Domestic" if firmtype_alt==2
	replace label = "Private Multinational" if firmtype_alt==3
	replace label = "Large Private Domestic" if firmtype_alt==4
	replace label = "Small Private Domestic" if firmtype_alt==5

g pubmne = firmtype_alt==1
g pubdom = firmtype_alt==2
g prvmne = firmtype_alt==3
g lprvdom = firmtype_alt==4
g sprvdom = firmtype_alt==5

*Industry group together industries
g naics2_mod = naics2
	replace naics2_mod = 30 if naics2==31 | naics2==32 | naics2==33
	replace naics2_mod = 44 if naics2==45
	replace naics2_mod = 48 if naics2==49
*Industry variable for plot (gets rid of gaps)
gegen naics_plot = group(naics2_mod)	
g freqweight = round(weightSOI*1000)

/*Plot is the share of industries for each firmtype_alt. 
	What share of private domestic are in manufacturing */

forvalues f=1/5{
	
twoway hist naics_plot [fw=freqweight] if firmtype_alt==`f', color(blue%40) horizontal disc percent ysc(reverse) ///
	ylab(1 "Agriculture " 2 "Mining, Oil, & Gas" 3 "Utilities" ///
	4 "Construction" 5 "Manufacturing"  ///
	6 "Wholesale" 7 "Retail" 8 "Trans. & Wareh." ///
	9 "Information" 10 "Finance & Insur." 11 "Real Est., Rent, Leas." ///
	12 "Prof. Services" 13 "Management" 14 "Administration, etc." 15 "Education" ///
	16 "Health" 17 "Art, etc." 18 "Lodging & Food" 19 "Other Services" ///
	20 "Public Admin.", labsize(medium))  xscale(range(0 35)) xlab(0(10)30,labsize(medium)) ///
	xtitle("Percent", size(medlarge)) /// 
	ytitle("Industry", size(medlarge)) graphregion(color(white) fcolor(white)) bgcolor(white)
	graph export $results/industry_withintype_`f'.png , replace width(3000)
}	
